<template>
    <div>
        <el-form
                ref="dataForm"
                status-icon
                :model="form"
                :rules="rules"
                label-width="0px"
        >
            <template>
                <div>
                    <h5>基本信息</h5>
                    <el-divider></el-divider>
                </div>
            </template>
            <el-descriptions :column="4" border>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 姓名</template>
                    <div>{{ user.name }}</div>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">身份证号码</template>
                    <div>{{ user.sfz }}</div>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">系统唯一识别码</template>
                    <div>{{ user.id_num }}</div>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label">联系电话</template>
                    <div>{{ user.phone }}</div>
                </el-descriptions-item>
                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 90%"
                        span="4"
                >
                    <template slot="label">联系地址</template>
                    <div>
                        {{ user.province_name }} {{ user.city_name }}
                        {{ user.district_name }} {{ user.town_name }}
                        {{ user.village_name }} {{ user.address }}
                    </div>
                </el-descriptions-item>
            </el-descriptions>

            <template>
                <div>
                    <h5>诊断信息</h5>
                    <el-divider></el-divider>
                </div>
            </template>
            <el-descriptions :column="4" border>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 住院号</template>
                    <el-form-item prop="admission_number">
                        <el-input v-model="form.admission_number" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 诊断单位</template>
                    <el-form-item prop="diagnostics_unit">
                        <el-input v-model="form.diagnostics_unit" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 诊断医师</template>
                    <el-form-item prop="diagnostics_doctor">
                        <el-input v-model="form.diagnostics_doctor" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 诊断方式</template>
                    <el-form-item prop="diagnostics_mode">
                        <el-select
                                clearable
                                placeholder="请选择"
                                style="width: 100%"
                                v-model="form.diagnostics_mode"
                        >
                            <el-option
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value"
                                    v-for="item in diagnosticsModeList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 复核单位</template>
                    <el-form-item prop="review_unit">
                        <el-input v-model="form.review_unit" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 复核医师</template>
                    <el-form-item prop="review_doctor">
                        <el-input v-model="form.review_doctor" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 复核日期</template>
                    <el-form-item prop="review_date">
                        <el-date-picker
                                style="width: 100%"
                                v-model="form.review_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                ></el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                >
                    <template slot="label"> 临床处理意见</template>
                    <el-form-item prop="clinic_opinion">
                        <el-input v-model="form.clinic_opinion" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 临床医师</template>
                    <el-form-item prop="review_doctor">
                        <el-input v-model="form.clinic_doctor" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 临床意见日期</template>
                    <el-form-item prop="clinic_date">
                        <el-date-picker
                                style="width: 100%"
                                v-model="form.clinic_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                ></el-descriptions-item>

            </el-descriptions>

            <template>
                <div>
                    <h5>治疗方式</h5>
                    <el-divider></el-divider>
                </div>
            </template>
            <el-descriptions :column="4" border>
                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 90%"
                        span="4"
                >
                    <template slot="label"> 是否治疗</template>
                    <el-form-item prop="is_treatment">
                        <el-radio-group v-model="form.is_treatment" @change="treatmentChange">
                            <el-radio
                                    v-for="(item, index) in treatmentList"
                                    :key="index"
                                    :label="item.value"
                            >{{ item.text }}
                            </el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>

            <el-descriptions :column="4" border v-if="form.is_treatment == '1'">
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 治疗方式</template>
                    <el-form-item prop="treatment_method">
                        <el-input v-model="form.treatment_method" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 治疗单位</template>
                    <el-form-item prop="treatment_unit">
                        <el-input v-model="form.treatment_unit" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 治疗医师</template>
                    <el-form-item prop="treatment_unit_doctor">
                        <el-input v-model="form.treatment_unit_doctor" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label"> 开始治疗时间</template>
                    <el-form-item prop="treatment_date">
                        <el-date-picker
                                style="width: 100%"
                                v-model="form.treatment_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 手术方式</template>
                    <el-form-item prop="modus_operandi">
                        <el-select
                                clearable
                                placeholder="请选择"
                                style="width: 100%"
                                v-model="form.modus_operandi"
                        >
                            <el-option
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value"
                                    v-for="item in modusOperandiList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 手术术式</template>
                    <el-form-item prop="operation_mode">
                        <el-select
                                clearable
                                placeholder="请选择"
                                style="width: 100%"
                                v-model="form.operation_mode"
                                clearable
                        >
                            <el-option
                                    :key="item.value"
                                    :label="item.text"
                                    :value="item.value"
                                    v-for="item in operationModeList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%"></el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 65%"></el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                        span="3"
                >
                    <template slot="label"> 术前辅助治疗</template>
                    <el-form-item prop="preoperative">
                        <el-radio-group v-model="form.preoperative">
                            <el-radio
                                    v-for="(item, index) in preoperativeList"
                                    :key="index"
                                    :label="item.value"
                            >{{ item.text }}
                            </el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 其他治疗</template>
                    <el-form-item prop="preoperative_other">
                        <el-input v-model="form.preoperative_other" clearable
                                  :disabled="form.preoperative!='6'"></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                        span="3"
                >
                    <template slot="label"> 术后辅助治疗</template>
                    <el-form-item prop="postoperation">
                        <el-radio-group v-model="form.postoperation">
                            <el-radio
                                    v-for="(item, index) in postoperationList"
                                    :key="index"
                                    :label="item.value"
                            >{{ item.text }}
                            </el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 其他治疗</template>
                    <el-form-item prop="postoperation_other">
                        <el-input v-model="form.postoperation_other" clearable
                                  :disabled="form.postoperation!='6'"></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                        span="3"
                >
                    <template slot="label"> 晚期治疗</template>
                    <el-form-item prop="later_period">
                        <el-radio-group v-model="form.later_period">
                            <el-radio
                                    v-for="(item, index) in laterPeriodList"
                                    :key="index"
                                    :label="item.value"
                            >{{ item.text }}
                            </el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 其他治疗</template>
                    <el-form-item prop="later_period_other">
                        <el-input v-model="form.later_period_other" clearable
                                  :disabled="form.later_period!='6'"></el-input>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>

            <el-descriptions :column="4" border v-if="form.is_treatment == '1'">
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 90%">
                    <template slot="label"> 淋巴结</template>
                    <el-table :data="form.lymph" style="width: 100%">
                        <template slot="empty">
                            <div class="emptyText">暂无数据</div>
                            <el-button type="primary" @click="addItem()">添加</el-button>
                        </template>

                        <el-table-column prop="location" label="位置">
                            <template slot-scope="scope">
                                <el-select clearable placeholder="请选择" style="width: 100%"
                                           v-model="scope.row.location">
                                    <el-option
                                            :key="item.value"
                                            :label="item.text"
                                            :value="item.value"
                                            v-for="item in locationList"
                                    >
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>

                        <el-table-column prop="lymph_group" label="淋巴结组别">
                            <template slot-scope="scope">
                                <el-select clearable placeholder="请选择" style="width: 100%"
                                           v-model="scope.row.lymph_group">
                                    <el-option
                                            :key="item.value"
                                            :label="item.text"
                                            :value="item.value"
                                            v-for="item in lymphGroupList"
                                    >
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>

                        <el-table-column prop="sweep_num" label="清扫个数">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.sweep_num" placeholder="请输入清扫个数"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column prop="positive_num" label="阳性个数">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.positive_num" placeholder="请输入阳性个数"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column prop="diolame" label="包膜是否完整">
                            <template slot-scope="scope">
                                <el-select clearable placeholder="请选择" style="width: 100%"
                                           v-model="scope.row.diolame">
                                    <el-option
                                            :key="item.value"
                                            :label="item.text"
                                            :value="item.value"
                                            v-for="item in diolameList"
                                    >
                                    </el-option>
                                </el-select>
                            </template>
                        </el-table-column>

                        <el-table-column label="操作" width="100">
                            <template slot-scope="scope">
                                <el-button
                                        type="primary"
                                        class="el-icon-plus"
                                        @click="addItem()"
                                        size="small"
                                        v-if="scope.$index == 0"
                                >添加
                                </el-button>
                                <el-button
                                        type="danger"
                                        class="el-icon-minus"
                                        @click="deleteItem(scope.$index)"
                                        size="small"
                                        v-else
                                >删除
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-descriptions-item>
            </el-descriptions>

            <template v-if="form.is_treatment == '0'">
                <div>
                    <h5>未治疗原因及处理意见</h5>
                    <el-divider></el-divider>
                </div>
            </template>
            <el-descriptions :column="4" border v-if="form.is_treatment == '0'">
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 未治疗原因</template>
                    <el-form-item prop="treatment_uncompleted_reason">
                        <el-input v-model="form.treatment_uncompleted_reason" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 15%"
                >
                    <template slot="label"> 未治疗处理意见</template>
                    <el-form-item prop="treatment_uncompleted_reason_other">
                        <el-input v-model="form.treatment_uncompleted_reason_other" clearable></el-input>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 经办人</template>
                    <el-form-item prop="responsible_person">
                        <el-select
                                clearable
                                placeholder="请选择"
                                style="width: 100%"
                                v-model="form.responsible_person"
                                clearable
                        >
                            <el-option
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.name"
                                    v-for="item in memberList"
                            >
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>

                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 15%">
                    <template slot="label"> 经办日期</template>
                    <el-form-item prop="responsible_date">
                        <el-date-picker
                                style="width: 100%"
                                v-model="form.responsible_date"
                                type="date"
                                placeholder="选择日期"
                                :value-format="'yyyy-MM-dd'"
                                clearable
                        >
                        </el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>

            <el-descriptions :column="4" border>
                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 90%"
                        span="4"
                >
                    <template slot="label"> 备注</template>
                    <el-form-item prop="remarks">
                        <el-input
                                v-model="form.remarks"
                                type="textarea"
                                clearable
                        ></el-input>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>

            <el-descriptions :column="4" border>
                <el-descriptions-item
                        labelStyle="width: 10%"
                        contentStyle="width: 90%"
                        span="4"
                >
                    <template slot="label"> 随访情况</template>
                    <el-table
                            :data="followData"
                            style="width: 100%">
                        <el-table-column
                                prop="follow_up_number"
                                label="随访次数">
                        </el-table-column>
                        <el-table-column
                                prop="name"
                                label="重要事件">
                            <template slot-scope="scope">
                                <div v-if="scope.row.last_contact_state=='存活'">
                                    {{scope.row.treatment_zl}}
                                </div>
                                <div v-else-if="scope.row.last_contact_state=='死亡'">
                                    {{scope.row.primary_cause_of_death}}
                                </div>
                                <div v-else-if="scope.row.last_contact_state=='失访'">
                                    {{scope.row.lost_visit}}
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column
                                prop="follow_up_time"
                                label="随访日期">
                        </el-table-column>
                        <el-table-column
                                prop="follow_up_doctor"
                                label="随访医生">
                        </el-table-column>
                    </el-table>
                </el-descriptions-item>
            </el-descriptions>

            <el-descriptions :column="1" border v-if="dialogStatus !== 'formal'">
                <el-descriptions-item labelStyle="width: 10%" contentStyle="width: 90%">
                    <el-form-item label=" ">
                        <el-button @click="handleDialogVisible(false)" size="small"
                        >取 消
                        </el-button
                        >
                        <el-button
                                type="primary"
                                @click="!form.id ? create() : update()"
                                size="small"
                        >确 定
                        </el-button>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>
        </el-form>
    </div>
</template>

<script>
    import {
        createTreatmentSituation,
        updateTreatmentSituation,
        readTreatmentSituation,
        historyTreatmentSituation
    } from "@/api/treatmentSituation/treatmentSituation";
    import {listMember} from "@/api/member/member";

    export default {
        props: ["rowData", "dialogStatus"],
        components: {},
        data() {
            return {
                followData: [],
                user: {},
                form: {
                    id: "",
                    user_id: "",
                    admission_number: "",//住院号
                    diagnostics_unit: "",//诊断单位
                    diagnostics_doctor: "",//诊断医师
                    diagnostics_mode: "",//诊断方式
                    review_unit: "",//复核单位
                    review_doctor: "",//复查医师
                    review_date: "",//复核日期
                    clinic_opinion: "",//临床处理意见
                    clinic_doctor: "",//临床医师
                    clinic_date: "",//临床意见日期
                    is_treatment: 1,//是否治疗
                    treatment_method: "",//治疗方式
                    treatment_unit: "",//治疗单位
                    treatment_unit_doctor: "",//治疗医师
                    treatment_date: "",//开始治疗时间
                    modus_operandi: "",//手术方式
                    operation_mode: "",//手术术式
                    preoperative: "",//术前辅助治疗
                    preoperative_other: "",//其他治疗
                    postoperation: "",//术后辅助治疗
                    postoperation_other: "",//其他治疗
                    later_period: "",//晚期治疗
                    later_period_other: "",//其他治疗
                    lymph: [],//淋巴结
                    treatment_uncompleted_reason: "",//未治疗原因
                    treatment_uncompleted_reason_other: "",//未治疗处理意见
                    responsible_person: "",//经办人
                    responsible_date: "",//经办日期
                    remarks: "",//备注
                },
                rules: {
                    // diagnostics_unit: [{required: true, trigger: "blur", message: "请输入诊断单位"}],
                    // diagnostics_doctor: [{required: true, trigger: "blur", message: "请输入诊断医师"}],
                    // diagnostics_mode: [{required: false, trigger: "blur", message: "请输入诊断方式"}],
                    // review_unit: [{required: true, trigger: "blur", message: "请输入复核单位"}],
                    // review_doctor: [{required: true, trigger: "blur", message: "请输入复查医师"}],
                    // review_date: [{required: true, trigger: "blur", message: "请输入复核日期"}],
                    // clinic_opinion: [{required: true, trigger: "blur", message: "请输入临床处理意见"}],
                    // clinic_doctor: [{required: true, trigger: "blur", message: "请输入临床医师"}],
                    // clinic_date: [{required: true, trigger: "blur", message: "请输入临床意见日期"}],
                    // is_treatment: [{required: true, trigger: "blur", message: "请输入是否治疗"}],
                    // treatment_method: [{required: true, trigger: "blur", message: "请输入治疗方式"}],
                    // treatment_unit: [{required: true, trigger: "blur", message: "请输入治疗单位"}],
                    // treatment_unit_doctor: [{required: true, trigger: "blur", message: "请输入治疗医师"}],
                    // treatment_date: [{required: true, trigger: "blur", message: "请输入开始治疗时间"}],
                    // modus_operandi: [{required: true, trigger: "blur", message: "请输入手术方式"}],
                    // operation_mode: [{required: true, trigger: "blur", message: "请输入手术术式"}],
                    // preoperative: [{required: true, trigger: "blur", message: "请输入术前辅助治疗"}],
                    // postoperation: [{required: true, trigger: "blur", message: "请输入术后辅助治疗"}],
                    // later_period: [{required: true, trigger: "blur", message: "请输入晚期治疗"}],
                    // treatment_uncompleted_reason: [{required: false, trigger: "blur", message: "请输入未治疗原因"}],
                    // treatment_uncompleted_reason_other: [{required: false, trigger: "blur", message: "请输入未治疗处理意见"}],
                    // responsible_person: [{required: true, trigger: "blur", message: "请输入经办人"}],
                    // responsible_date: [{required: true, trigger: "blur", message: "请输入经办日期"}],
                },
                createLoading: false,
                updateLoading: false,
                memberList: [],

                diagnosticsModeList: [
                    {text: "LDCT 筛查检出", value: 1,},
                    {text: "因症状检出（期间病例）", value: 2,},
                    {text: "筛查后病例", value: 3,},
                ],
                treatmentList: [
                    {text: "否", value: 0,},
                    {text: "是", value: 1,},
                ],
                preoperativeList: [
                    {text: "新辅助化疗", value: 1},
                    {text: "新辅助放疗", value: 2},
                    {text: "新辅助放化疗", value: 3},
                    {text: "新辅助分子靶向治疗", value: 4},
                    {text: "新辅助免疫治疗", value: 5},
                    {text: "其他治疗（注明）", value: 6}
                ],
                postoperationList: [
                    {text: "辅助化疗", value: 1},
                    {text: "辅助放疗", value: 2},
                    {text: "辅助放化疗", value: 3},
                    {text: "辅助分子靶向治疗", value: 4},
                    {text: "辅助免疫治疗", value: 5},
                    {text: "其他治疗（注明）", value: 6}
                ],
                laterPeriodList: [
                    {text: "化疗", value: 1},
                    {text: "靶向治疗", value: 2},
                    {text: "放疗", value: 3},
                    {text: "免疫治疗", value: 4},
                    {text: "姑息手术", value: 5},
                    {text: "其他治疗（注明）", value: 6}
                ],
                modusOperandiList: [
                    {text: "胸腔镜", value: 1},
                    {text: "开胸肺切除", value: 2},
                    {text: "胸腔镜辅助肺切除", value: 3},
                ],
                operationModeList: [
                    {text: "楔形切除", value: 1},
                    {text: "肺段切除", value: 2},
                    {text: "肺叶切除", value: 3},
                    {text: "全肺切除", value: 4},
                    {text: "支气管成形肺叶切除", value: 5},
                    {text: "肺切除联合其他受侵器官切除（上腔静脉、气管、左心房、主动脉、食管）", value: 6},
                ],
                locationList: [
                    {text: "左侧", value: 1},
                    {text: "右侧", value: 2},
                ],
                lymphGroupList: [
                    {text: "2R", value: 1},
                    {text: "3a", value: 2},
                    {text: "3p", value: 3},
                    {text: "4R", value: 4},
                    {text: "4L", value: 5},
                    {text: "5", value: 6},
                    {text: "6", value: 7},
                    {text: "7", value: 8},
                    {text: "8", value: 9},
                    {text: "9", value: 10},
                    {text: "10", value: 11},
                    {text: "11", value: 12},
                    {text: "12", value: 13},
                    {text: "13", value: 14},
                    {text: "14", value: 15},
                ],
                diolameList: [
                    {text: "否", value: 0},
                    {text: "是", value: 1},
                ],
            };
        },
        created() {
            this.getListMember();
            if (this.dialogStatus == "update" || this.dialogStatus == "formal") {
                this.user = {...this.rowData};
                this.read();
            }
        },
        methods: {
            addItem() {
                this.form.lymph.push({
                    location: "",
                    lymph_group: "",
                    sweep_num: "",
                    positive_num: "",
                    diolame: "",
                });
            },
            deleteItem(index) {
                this.form.lymph.splice(index, 1);
            },
            treatmentChange(value) {
                if (value == 1) {
                    this.rules.treatment_method[0].required = true;
                    this.rules.treatment_unit[0].required = true;
                    this.rules.treatment_unit_doctor[0].required = true;
                    this.rules.treatment_date[0].required = true;
                    this.rules.modus_operandi[0].required = true;
                    this.rules.operation_mode[0].required = true;
                    this.rules.preoperative[0].required = true;
                    // this.rules.preoperative_other[0].required = true;
                    this.rules.postoperation[0].required = true;
                    // this.rules.postoperation_other[0].required = true;
                    this.rules.later_period[0].required = true;
                    // this.rules.later_period_other[0].required = true;
                    // this.rules.lymph[0].required = true;
                    this.rules.treatment_uncompleted_reason[0].required = false;
                    this.rules.treatment_uncompleted_reason_other[0].required = false;
                } else {

                    this.rules.treatment_method[0].required = false;
                    this.rules.treatment_unit[0].required = false;
                    this.rules.treatment_unit_doctor[0].required = false;
                    this.rules.treatment_date[0].required = false;
                    this.rules.modus_operandi[0].required = false;
                    this.rules.operation_mode[0].required = false;
                    this.rules.preoperative[0].required = false;
                    // this.rules.preoperative_other[0].required = false;
                    this.rules.postoperation[0].required = false;
                    // this.rules.postoperation_other[0].required = false;
                    this.rules.later_period[0].required = false;
                    // this.rules.later_period_other[0].required = false;
                    // this.rules.lymph[0].required = false;
                    this.rules.treatment_uncompleted_reason[0].required = true;
                    this.rules.treatment_uncompleted_reason_other[0].required = true;
                }
            },
            getListMember() {
                let params = {
                    user_name: "",
                    status: "",
                    institution_id: this.$store.state.member.institution_id,
                    pageSize: 1000,
                    page: 1,
                };
                listMember(params).then((res) => {
                    if (res.code === 200) {
                        this.memberList = res.data.data;
                    } else {
                        this.msgError(res.msg);
                    }
                });
            },
            //父页面的回调事件
            handleDialogVisible(isUpdate) {
                this.dialogVisible = false;
                this.$emit("childByDialogVisible", this.dialogVisible, isUpdate);
            },
            //获取数据
            read() {
                readTreatmentSituation({id: this.user.id}).then((response) => {
                    if (response.code == 200) {
                        if (response.data != null) {
                            this.form = response.data;
                            if (this.form.lymph) {
                                this.form.lymph = JSON.parse(this.form.lymph);
                            } else {
                                this.form.lymph = [];
                            }
                        } else {
                            this.form.user_id = this.user.id;
                            this.form.is_treatment = 1;
                        }
                    }
                });

                historyTreatmentSituation({sfz: this.user.sfz}).then((response) => {
                    if (response.code == 200) {
                        if (response.data != null) {
                            this.followData = response.data;
                        }
                    }
                });
            },
            //创建
            create() {
                this.$refs["dataForm"].validate((valid) => {
                    if (valid) {
                        this.createLoading = true;
                        createTreatmentSituation(this.form).then((response) => {
                            this.createLoading = false;
                            if (response.code == 200) {
                                this.msgSuccess(response.msg);
                                this.handleDialogVisible(true);
                            }
                        });
                    }
                });
            },
            //修改
            update() {
                this.$refs["dataForm"].validate((valid) => {
                    if (valid) {
                        this.updateLoading = true;
                        updateTreatmentSituation(this.form).then((response) => {
                            this.updateLoading = false;
                            if (response.code == 200) {
                                this.msgSuccess(response.msg);
                                this.handleDialogVisible(true);
                            }
                        });
                    }
                });
            },
        },
        watch: {},
    };
</script>
<style lang="scss" scoped="scoped">
    .el-form-item {
        margin: 0px;
    }

    .red {
        color: red;
    }

    .el-form-item {
        margin: 0;
    }

    .el-ul {
        list-style: none;
        padding: 0;
    }

    .el-list-li {
        float: left;
        position: relative;
        padding: 10px 10px 0px 0px;
    }

    .el-icon-circle-close {
        position: absolute;
        top: 0px;
        right: 0px;
        z-index: 2;
        font-size: 20px;
    }
</style>
